/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   Module Name          : com.yaodian100.ec.givebonus.service.impl.BonusSettingServiceImpl
   Module Description   :

   Date Created      : 2010/11/8
   Original Author   : afra.chou
   Team              : yaodian100
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   MODIFICATION HISTORY
   ------------------------------------------------------------------------------
   Date Modified       Modified by       Comments
   ------------------------------------------------------------------------------
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
package com.yaodian100.ec.givebonus.service.impl;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import com.yaodian100.core.common.dao.impl.CommonCriteria;
import com.yaodian100.core.common.service.impl.DomainServiceImpl;
import com.yaodian100.ec.givebonus.entity.BonusSetting;
import com.yaodian100.ec.givebonus.service.BonusSettingService;

/**
 * @author afra.chou
 * 
 */
public class BonusSettingServiceImpl extends DomainServiceImpl<BonusSetting> implements BonusSettingService {

	public BonusSetting getLowestDiscount(BigDecimal orderPrice) {
		Date now = new Date();
		CommonCriteria cc = new CommonCriteria();
		cc.addGe("endDt", now);
		cc.addLe("startDt", now);
		cc.addGe("orderPriceMax", orderPrice);
		cc.addLe("orderPriceMin", orderPrice);
		cc.addEq("status", "Y");
		List<BonusSetting> settings = getList(0, -1, cc, new String[] { "percentage desc", "discountLimit desc" });
		if (settings.size() > 0) {
			return settings.get(0);
		} else {
			return null;
		}
	}
}
